home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / TEMP / GNU / bison / ExpectDecl < prev    next >
Text File  |  1995-06-28  |  2KB  |  50 lines

  1. Expect Decl
  2. Previous: <Type Decl=>TypeDecl> * Next: <Start Decl=>StartDecl> * Up: <Declarations=>Declaratio>
  3.  
  4. #Wrap on
  5. {fH4}Suppressing Conflict Warnings{f}
  6.  
  7. Bison normally warns if there are any conflicts in the grammar
  8. (\*Note <Shift\/Reduce=>ShiftRedud>: Shift\/Reduce Conflicts), but most real grammars have harmless shift\/reduce
  9. conflicts which are resolved in a predictable way and would be difficult to
  10. eliminate.  It is desirable to suppress the warning about these conflicts
  11. unless the number of conflicts changes.  You can do this with the
  12. {fCode}%expect{f} declaration.
  13.  
  14. The declaration looks like this:
  15.  
  16. #Wrap off
  17. #fCode
  18. %expect {fStrong}n{f}
  19. #f
  20. #Wrap on
  21.  
  22. Here {fStrong}n{f} is a decimal integer.  The declaration says there should be no
  23. warning if there are {fStrong}n{f} shift\/reduce conflicts and no reduce\/reduce
  24. conflicts.  The usual warning is given if there are either more or fewer
  25. conflicts, or if there are any reduce\/reduce conflicts.
  26.  
  27. In general, using {fCode}%expect{f} involves these steps:
  28.  
  29. #Indent +4
  30.  
  31.  • Compile your grammar without {fCode}%expect{f}.  Use the {fEmphasis}-v{f} option
  32. to get a verbose list of where the conflicts occur.  Bison will also
  33. print the number of conflicts.
  34.  
  35.  
  36.  • Check each of the conflicts to make sure that Bison's default
  37. resolution is what you really want.  If not, rewrite the grammar and
  38. go back to the beginning.
  39.  
  40.  
  41.  • Add an {fCode}%expect{f} declaration, copying the number {fStrong}n{f} from the
  42. number which Bison printed.
  43.  
  44. #Indent
  45.  
  46. Now Bison will stop annoying you about the conflicts you have checked, but
  47. it will warn you again if changes in the grammar result in additional
  48. conflicts.
  49.  
  50.